import { ref } from 'vue'
export function useTimes() {
  const date = new Date()
  const curTime = ref({
    year: date.getFullYear(),
    month: date.getMonth(),
    day: date.getDate(),
    hours: date.getHours(),
    minutes: date.getMinutes(),
    seconds: date.getSeconds(),
  })
  const timer = setInterval(() => {
    const date = new Date()
    curTime.value.year = date.getFullYear()
    curTime.value.month = date.getMonth()
    curTime.value.day = date.getDate()
    curTime.value.hours = date.getHours()
    curTime.value.minutes = date.getMinutes()
    curTime.value.seconds = date.getSeconds()
  }, 1000)

  return { curTime, timer }
}
